package com.hx.localmiaosha.web;

import com.hx.common.R;
import com.hx.localmiaosha.service.MiaoShaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Author wonghiu
 * @Date 2021/6/4 23:55
 * @Version 1.0.1
 */
@Controller
@RequestMapping("/miaosha")
public class MiaoShaController {
    @Autowired
    private MiaoShaService miaoShaService;

    @PostMapping(value = "/kill")
    @ResponseBody
    public R kill(@RequestParam("goodsId") Long goodsId, @RequestParam("randomCode") String randomCode){
        System.out.println(goodsId+randomCode);
        Long orderId = miaoShaService.kill(goodsId,randomCode);
        System.out.println(orderId);
        if (orderId!=null){
            return R.ok().put("orderId",String.valueOf(orderId));
        }else {
            return R.error();
        }
    }
}
